package com.neusoft.elmboot.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.User;

@Mapper
public interface UserMapper {

	@Select("select userId,userName,userSex,userImg,isBusiness from user where userId=#{userId} and password=#{password}")
	public User getUserByIdByPass(User user);
	
	@Select("select count(*) from user where userId=#{userId}")
	public int getUserById(String userId);
	
	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,0)")
	public int saveUser(User user);
	
	@Update("update user set userImg=#{userImg} where userId=#{userId}")
	public int updateUserImgById(User user);
	
	@Update("update user set userName=#{userName},userSex=#{userSex} where userId=#{userId}")
	public int updateUserById(User user);
	
	@Update("update user set password=#{password} where userId=#{userId}")
	public int updatePasswordById(User user);
	
	@Update("update user set isBusiness=1 where userId=#{userId}")
	public int becomeBusiness(String userId);
	
	@Select("select isBusiness from user where userId=#{userId}")
	public int IsBusiness(String userId);
	
	@Select("select right(password,8) from user where userId=#{userId}")
	public String getSaltById(String userId);
}